//
//  AppInfo.m
//  05-应用管理
//
//  Created by wangneihan on 15/12/13.
//  Copyright © 2015年 wangneihan. All rights reserved.
//

#import "AppInfo.h"

@implementation AppInfo

-(instancetype)initWithDic:(NSDictionary *) dic{
    
    if(self = [self init])
    {
        self.name = dic[@"name"];
        self.icon = dic[@"icon"];
    }
    return self;
    
}

+(instancetype)appInitWithDic:(NSDictionary *) dic{
    
    return  [[self alloc] initWithDic:dic];
    
}

+(NSArray *)getAppInfo{
    
    NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"app" ofType:@"plist"];
    
    NSArray *baseArray = [NSArray arrayWithContentsOfFile:bundlePath];
    
    NSMutableArray *tempArray = [[NSMutableArray alloc]init];
    
    for (NSDictionary *dic in baseArray) {
        
        AppInfo *tempInfo = [AppInfo appInitWithDic:dic];
        
        [tempArray addObject:tempInfo];
    }
    
    return tempArray;
    
}
@end
